#include "reader.h"
#include <QtTest/QTest>

Reader::Reader(Shelf *shelf, int time, QObject *parent) :
    shelf(shelf), time(time), QObject(parent)
{
}

void Reader::run(){
    while(true){
        if(shelf->size() == 0) continue;
        int pos = qrand() % shelf->size();
        emit wait();
        shelf->takeBook(pos);
        emit read();
        QTest::qSleep(time*1000);
        shelf->putBook(pos);
    }
}
